#include<bits/stdc++.h>
using namespace std;
struct node{
    int d,v,a;
    double s;
}c[100005];
int p[100005];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    bool flag1=true,flag2=true;
    cin>>t;
    while(t--){
        int n,m,l,V;
        int ans1=0,ans2=0;
        int maxn=-1;
        cin>>n>>m>>l>>V;
        for(int i=1;i<=n;i++){
            cin>>c[i].d>>c[i].v>>c[i].a;
            if(c[i].a!=0) flag1=false;
            if(c[i].a<=0) flag2=false;
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
            maxn=max(maxn,p[i]);
        }
        if(flag1==true){
            for(int i=1;i<=n;i++){
                if(c[i].v>V&&c[i].d<=maxn){
                    ans1++;
                }
            }
            if(ans1==0) ans2=m;
            else ans2=m-1;
        }
        else if(flag2==true){
                for(int i=1;i<=n;i++){
                    c[i].s=(V*V-c[i].v*c[i].v)/(2*c[i].a);
                    if(c[i].s+c[i].d<=maxn){
                        ans1++;
                }
                if(ans1==0) ans2=m;
                else ans2=m-1;
            }

        }
        cout<<ans1<<" "<<ans2<<endl;
    }
    return 0;
}
